package main

import (
	"fmt"
	"math/rand"
	"time"
)

func test1() {
	for i := 1; i < 10; i++ {
		for j := 1; j <= i; j++ {
			fmt.Printf("%v*%v=%v ", j, i, i*j)
		}
		fmt.Printf("\n")
	}
}

func test2() {
	src := rand.NewSource(time.Now().UnixNano())
	gen := rand.New(src)
	a := make([]int, 20)
	sum := 0
	num := 1
	for i := 0; i < len(a); i++ {
		a[i] = gen.Intn(100) + 1
		if i%2 == 0 {
			num *= a[i]
		} else {
			sum += a[i]
		}
	}
	fmt.Printf("和为%v, 积为%v\n", sum, num)
	fmt.Printf("随机数为%v\n", a)
}

func test3() {
	f := 0
	fprev := 1
	for f <= 100 {
		fmt.Println(f)
		f, fprev = fprev, f+fprev
	}
}

func main() {
	test1()
	test2()
	test3()
}
